/*
 * USARTLogging.cpp
 *
 *  Created on: 12.12.2012
 *      Author: Lapchinskiy
 */
#include "BuildConfig.h"
#include "Global_types.h"
#include "TimeManager.h"
#include "SerialInterface.h"
#include <iostream>
#include <stdio.h>
#include "Logging.h"
char const  *ModuleToStringTable[] = { "Task", "Driver", "UART", "Sensor", "Scheduler","" };
 char const *ErrorToStringTable[] = { "No error", "FAILURE", "" };
void Log(char *string) {
#ifdef USART_DEBUG
	    uint8_t* tmpStr;
		SerialPutString("-> Time: ");
		SerialPutIntegerAsString(TimeManager::systemTime);
		SerialPutString(": ");
#endif //USART_DEBUG
}
void Log(ModuleType module, ErrorCode error, char *string) {

#ifdef USART_DEBUG
		SerialPutString("-> Time: ");
		SerialPutIntegerAsString(TimeManager::systemTime);
                SerialPutString(" ");
		SerialPutString("Module: ");
		SerialPutString(ModuleToStringTable[module]);
		SerialPutString(" ");
		SerialPutString(string);
		SerialPutString(" ");
		SerialPutString("Error: ");
	        SerialPutString(ErrorToStringTable[error]);
            //    SerialPutString("\r");
		SerialPutString("\n");
                
#endif //USART_DEBUG

}

void Log(LogRecord *logrec, ErrorCode error, char *string) {
#ifdef USART_DEBUG
		SerialPutString("-> Time: ");
		SerialPutIntegerAsString(TimeManager::systemTime);
                SerialPutString(" ");
		SerialPutString("Module: ");
		SerialPutString(ModuleToStringTable[logrec->module]);
		SerialPutString(" ");
		SerialPutString("\"");
		SerialPutString(logrec->objectName);
		SerialPutString("\" ");
		SerialPutString(string);
		SerialPutString(" ");
		SerialPutString("Error: ");
		SerialPutString(ErrorToStringTable[error]);
              //  SerialPutString("\r");
		SerialPutString("\n");
#endif //USART_DEBUG

}


